自定义Ceph存储部署


4. 配置 ceph osd

在stack用户目录下建立templates目录

  1. mkdir ~/templates

复制ceph 配置文件到templates目录中

  1. cp /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml ~/templates/

在storage-environment.yaml中添加一段ExtraConfig 的section,格式大致如下:

  1. parameter_defaults: #已存在的section
  2. ExtraConfig: #这是我们要添加的section
  3. ceph::profile::params::osds:

分别存储journal 和 osd

  1. ceph::profile::params::osds:
  2. '/dev/sdc':
  3. journal: '/dev/sdb'
  4. '/dev/sdd':
  5. journal: '/dev/sdb'

将journal 和osd 数据放在一个硬盘内

  1. ceph::profile::params::osds:
  2. '/dev/sdb': {}
  3. '/dev/sdc': {}
  4. '/dev/sdd': {}

wipe-disks.yaml

  1. heat_template_version: 2014-10-16
  2. description: >
  3. Wipe and convert all disks to GPT (except the disk containing the root file system)
  4. resources:
  5. userdata:
  6. type: OS::Heat::MultipartMime
  7. properties:
  8. parts:
  9. - config: {get_resource: wipe_disk}
  10. wipe_disk:
  11. type: OS::Heat::SoftwareConfig
  12. properties:
  13. config: {get_file: wipe-disk.sh}
  14. outputs:
  15. OS::stack_id:
  16. value: {get_resource: userdata}

wipe-disk.sh

  1. #!/bin/bash
  2. if [[ `hostname` = *"ceph"* ]]
  3. then
  4. echo "Number of disks detected: $(lsblk -no NAME,TYPE,MOUNTPOINT | grep "disk" | awk '{print $1}' | wc -l)"
  5. for DEVICE in `lsblk -no NAME,TYPE,MOUNTPOINT | grep "disk" | awk '{print $1}'`
  6. do
  7. ROOTFOUND=0
  8. echo "Checking /dev/$DEVICE..."
  9. echo "Number of partitions on /dev/$DEVICE: $(expr $(lsblk -n /dev/$DEVICE | awk '{print $7}' | wc -l) - 1)"
  10. for MOUNTS in `lsblk -n /dev/$DEVICE | awk '{print $7}'`
  11. do
  12. if [ "$MOUNTS" = "/" ]
  13. then
  14. ROOTFOUND=1
  15. fi
  16. done
  17. if [ $ROOTFOUND = 0 ]
  18. then
  19. echo "Root not found in /dev/${DEVICE}"
  20. echo "Wiping disk /dev/${DEVICE}"
  21. sgdisk -Z /dev/${DEVICE}
  22. sgdisk -g /dev/${DEVICE}
  23. else
  24. echo "Root found in /dev/${DEVICE}"
  25. fi
  26. done
  27. fi